//定义一个自增的变量，用来标示不同的tab页
var mainTabs;
	//定义一个默认的tab页
Ext.onReady(function(){
	 var treeLoader = new Ext.tree.TreeLoader({
		 url:'menu!findMenu.action'
	 });
	 treeLoader.on("beforeload", function(treeLoader, node) {
	        id = node.attributes.id;
	    }, this);

	 //根节点    
	 var root=new Ext.tree.AsyncTreeNode({    
		 id:"root",    
		 text:"控制面板", 
		 loader:treeLoader, 
		 expanded:true
		 
	 });   
	var mytree=new Ext.tree.TreePanel({
		   region:'west',
		   animate:true,    
	       title:"简单Extjs动态树",    
	       collapsible:true,    
	       enableDD:true,    
	       enableDrag:true,    
	       rootVisible:true,    
	       width:200,
	       frame:true,
	       lines:true,
	       root:root
	       //这里简简单单的loader的几行代码是取数据的,很经典哦    
	          
	   });    
	
//头部信息
var headerPanel = new Ext.Panel({	
	title:"头部",
	frame:"true",
    region: 'north',
    height:100,
    //html:"<iframe name='headFrame' src='title.jsp' scrolling='no' frameborder='0' width='100%' height='100%' ></iframe>"
	autoLoad:{
    	url:"title.jsp",
        scope: this, 
        discardUrl: true, 
        nocache: false, 
        text: "Loading...", 
        timeout: 30, 
        scripts: true
        }
}		
);
//底部信息
var footerPanel = new Ext.Panel({
		region: 'south',
        frame:"true",
        height: 50,
        html: '<center>Copyright © 2011-2011 YJCK Corporation, All Rights Reserved</center>'
        
});



 mainTabs= new Ext.TabPanel({
                region:'center', 
                activeTab:0,
                id:'mainTabs',
                enableTabScroll:true,
                height:550,
                border:false,
                frame:"true",
                items:[{
                      title:"我的工作台",
                     // listeners: {activate: function(){Ext.getCmp('centerPanel').setTitle('家庭日常管理系统');}},
                      html:"<iframe name='mainFrame' src='welcome.jsp' scrolling='auto' frameborder='0' width='100%' height='100%' ></iframe>"

                    }]

             });
 //主区域
var centerPanel = new Ext.Panel({
			region:'center',
			frame:"true",
            id: 'centerPanel', 
            title:'家庭管理系统',
            autoScroll:false,
            layout: 'fit',
            items:[mainTabs]
}	
);


//定义一个viewport，采用border布局
var viewport = new Ext.Viewport({
    layout: 'border',
    items: [
   		headerPanel, 
   		mytree,
    	footerPanel,
		centerPanel
	]
});	
});
 
  
function addTab(url,menuid,path,title){
	var myurl = url+"?tmp="+Math.random();
	 var n = Ext.getCmp("mainTabs").add({
			   id:'tab'+menuid,
		       title:title,
		       frame:"true",
		       closable:true,
		       layout:'fit',
		       listeners: {activate: function(){Ext.getCmp('centerPanel').setTitle(path)}},
		       html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src='+myurl+'></iframe>'
		      
	 });
	  Ext.getCmp("mainTabs").setActiveTab(n);
};





